﻿using System.Web.UI;

namespace NativeCode.Web.Extensions
{
	public static class ControlExtensions
	{
		public static string ToPostBackCaller(this Control control, string argument)
		{
			return control.ToPostBackCaller(argument, false);
		}
		public static string ToPostBackCaller(this Control control, string argument, bool forHref)
		{
			return string.Format(forHref
			                     	? "javascript:__doPostBack('{0}', '{1}');"
			                     	: "__doPostBack('{0}', '{1}');",
			                     control.UniqueID, argument);
		}
	}
}